/*
 * @Descripttion:
 * @Author: voanit
 * @Date: 2022-05-08 14:52:52
 * @LastEditors: voanit
 * @LastEditTime: 2022-05-08 15:59:54
 */
import React from 'react'

const Forth = (props) => {
  console.log(111222)
  /* url  query传参数据的获取 之函数封装 */
  var queryHandle = (url) => {
    // url => ?age=18&gender=1&hobby=swimming
    var url = url.slice(1)
    var arr = url.split('&')
    var obj = {}
    for (var item of arr) {
      var newArr = item.split('=')
      obj[newArr[0]] = newArr[1]
    }
    return obj
  }
  let age = queryHandle(props.location.search)['age']

  console.log(queryHandle(props.location.search)['age'], 999)

  /* 分步骤 */
  // var url = props.location.search.slice(1) // age=18&gender=1
  // var arr = url.split('&') // 【age=18，gender=1】
  // var obj = {}
  // // console.log(arr, 5)
  // for (var item of arr) {
  //   // console.log(item, 8899) // age=18 gender=1
  //   var newArr = item.split('=') // [age,18] [gender,1]
  //   // console.log(newArr, 8899)
  //   obj[newArr[0]] = newArr[1]
  // }
  // console.log(obj, 6666)
  return (
    <div>
      御剑乘风来,除魔天地间!===Forth ==== id:{props.match.params.id}
      姓名：{props.match.params.name}===={age}
    </div>
  )
}
export default Forth
/* 
age=18&gender=1
{
  age:18,
  gender:1
  }
*/
